Array [] do JavaScript
- Página anterior []
- Próxima página new Array()
- Voltar à página anterior Manual de Referência JavaScript Array
Definition and Usage
[ ]
The constructor is used to create a new array object.
Instance
Example 1
// Create an array const cars = ["Saab", "Volvo", "BMW"];
Example 2
Create an empty array and add values:
// Create an array const cars = []; // Add values to the array cars.push("Saab"); cars.push("Volvo"); cars.push("BMW");
Example 3
Using new Array()
Method to create an array:
// Create an array const cars = new Array(["Saab", "Volvo", "BMW"]);
Syntax
[iterable]
Parameter
Parameter | Description |
---|---|
iterable | Required. An iterable object containing values. |
Return Value
Type | Description |
---|---|
Array | New Array Object |
Browser Support
[]
The array constructor is a feature of ECMAScript1 (JavaScript 1997).
It is supported in all browsers:
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Supported | Supported | Supported | Supported | Supported | Supported |
- Página anterior []
- Próxima página new Array()
- Voltar à página anterior Manual de Referência JavaScript Array